﻿@model List<ResourceTreeViewModel>
@{ 
    UserIdentity user = ViewBag.User;
}
<nav class="navbar-default navbar-static-side" role="navigation">
    <div class="nav-close">
        <i class="fa fa-times-circle"></i>
    </div>
    <div class="sidebar-collapse">
        <ul class="nav" id="side-menu">
            <li class="nav-header">
                <div class="dropdown profile-element">
                    <span><img title="@user.UserName" name="userinfo" data-userid="@user.UserId" alt="@user.UserName" class="img-circle" style="width:65px;" src="@user.HeadImg" /></span>
                    <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                        <span class="clear">
                            <span class="text-muted text-xs block"><strong class="font-bold">@user.UserName</strong><b class="caret"></b></span>
                        </span>
                    </a>
                    <ul class="dropdown-menu animated fadeInRight m-t-xs">
                        <li>
                            <a class="J_menuItem" href="/Sys/User/Image">修改头像</a>
                        </li>
                        <li>
                            <a class="J_menuItem" href="/Sys/User/Show?id=@user.UserId">基本信息</a>
                        </li>
                        <li class="divider"></li>
                        <li>
                            <a href="/sys/user/logout">安全退出</a>
                        </li>
                    </ul>
                </div>
                <div class="logo-element">
                    MS
                </div>
            </li>
            @foreach (var item in Model)
            {
                <li>
                    <a>
                        <i class="@item.Icon"></i>
                        <span class="nav-label">@item.ResourceName</span>
                        <span class="fa arrow"></span>
                    </a>
                    @if (item.Children.HasItems())
                    {
                        <ul class="nav nav-second-level">
                            @foreach (var item2 in item.Children)
                            {
                                <li>
                                    @if (item2.Children.HasItems())
                                    {
                                        <a class="J_menuItem">
                                            <i class="@item2.Icon"></i>
                                            <span class="nav-label">@item2.ResourceName</span>
                                            <span class="fa arrow"></span>
                                        </a>
                                        <ul class="nav nav-third-level">
                                            @foreach (var item3 in item2.Children)
                                            {
                                                <li>
                                                    <a class="J_menuItem" href="@item3.ResourceUrl"><i class="@item3.Icon"></i>@item3.ResourceName</a>
                                                </li>
                                            }
                                        </ul>
                                    }
                                    else
                                    {
                                        <a class="J_menuItem" href="@item2.ResourceUrl"><i class="@item2.Icon"></i>@item2.ResourceName</a>
                                    }
                                </li>
                            }
                        </ul>
                    }
                </li>
            }
        </ul>

    </div>
</nav>